import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号

name_list = ['0', '5', '10', '15', '20', '25']
data = []
data.append([3919, 2272, 1555, 947, 419, 342])
data.append([3895, 2206, 1548, 920, 409, 337])
data.append([3894, 2187, 1564, 918, 410, 342])

x = list(range(len(name_list)))
total_width, n = 0.8, len(data)
width = total_width / n

# 设置刻度字体大小
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
#设置坐标轴名称
plt.xlabel('平均节点通道数', fontsize=15)
plt.ylabel('交易执行耗时', fontsize=15)

'''
for i in range(5):
    plt.bar(x, data[0], width=width, label='步长 = '+str(i), fc='g')
    for i in range(len(x)):
        x[i] = x[i] + width
'''

plt.bar(x, data[0], width=width, label='30交易/周期')
for i in range(len(x)):
    x[i] = x[i] + width
plt.bar(x, data[1], width=width, label='20交易/周期', tick_label=name_list)
for i in range(len(x)):
    x[i] = x[i] + width
plt.bar(x, data[2], width=width, label='10交易/周期')
for i in range(len(x)):
    x[i] = x[i] + width
# plt.bar(x, data[3], width=width, label='4个分片')
for i in range(len(x)):
    x[i] = x[i] + width
# plt.bar(x, data[4], width=width, label='重连概率=1')
plt.legend()
plt.show()